package com.hospital.register.oss.controller;

import com.hospital.register.common.result.Result;
import com.hospital.register.oss.service.OssService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.constraints.NotNull;

@Api(tags = "oss 相关请求")
@RestController
@RequestMapping("/api/oss/file")
@Validated
public class OssController {

    /**
     * 处理 oss 相关业务
     */
    @Autowired
    private OssService ossService;

    @ApiOperation(value = "上传文件")
    @PostMapping("/fileUpload")
    public Result<String> fileUpload(@NotNull(message = "必须上传文件") MultipartFile file) {
        return Result.ok(this.ossService.upload(file));
    }

}
